{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "547c015e-c328-45f0-b904-47016ed8d377",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import autogen\n",
    "from autogen.cache import Cache"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "91b8f5d1-ca9d-4ed3-9fba-c5a1e94a59fc",
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "import os\n",
    "# Add the parent directory to the system path\n",
    "parent_directory = os.path.abspath(os.path.join(os.getcwd(), '..'))\n",
    "if parent_directory not in sys.path:\n",
    "    sys.path.insert(0, parent_directory)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "ee50f8ce-9b70-43db-ad3f-29da9dd45fb5",
   "metadata": {},
   "outputs": [],
   "source": [
    "!pip install langchain-chroma -U -q\n",
    "!pip install sentence-transformers -q"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "6caff0bb-b5f4-486c-9215-6ec97de64eb8",
   "metadata": {},
   "outputs": [],
   "source": [
    "from finrobot.data_source.earnings_calls_src.main_earningsData import get_earnings_all_docs\n",
    "from finrobot.data_source.earnings_calls_src import earningsData\n",
    "from finrobot.data_source.filings_src import sec_main as unstructured_sec_main\n",
    "from finrobot.data_source.earnings_calls_src.main_earningsData import get_earnings_all_docs\n",
    "from finrobot.data_source.earnings_calls_src import earningsData\n",
    "from langchain.text_splitter import RecursiveCharacterTextSplitter\n",
    "from langchain_chroma import Chroma\n",
    "from langchain_community.embeddings.sentence_transformer import SentenceTransformerEmbeddings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "992ee4ff-3310-4a98-864d-2e3297582884",
   "metadata": {},
   "outputs": [],
   "source": [
    "from finrobot.functional.ragquery import rag_database_earnings_call\n",
    "from finrobot.functional.ragquery import rag_database_sec"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "4dda7841-8e4d-4649-802d-09fa279299ec",
   "metadata": {},
   "outputs": [],
   "source": [
    "#ticker = 'GOOG'\n",
    "ticker = 'NVDA'\n",
    "year = '2023'\n",
    "filing_types = ['10-K','10-Q']\n",
    "include_amends = True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "e49b24a9-6f76-4045-b0d0-8a00d8bd6d58",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Earnings Call Q1\n",
      "Earnings Call Q2\n",
      "Earnings Call Q3\n",
      "Earnings Call Q4\n"
     ]
    }
   ],
   "source": [
    "query_database_earnings_call, earnings_call_quarter_vals, quarter_speaker_dict = rag_database_earnings_call(ticker = ticker, year = year)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "1746ee5a-3fa7-4d5b-b526-7f767440b387",
   "metadata": {},
   "outputs": [],
   "source": [
    "global FROM_MARKDOWN\n",
    "FROM_MARKDOWN = False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "fec8d299-ee74-4db3-aac3-f941b075fa72",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Started Scraping\n",
      "Scraped\n",
      "Started Extracting\n",
      "Extracted\n"
     ]
    }
   ],
   "source": [
    "query_database_sec, sec_form_names = rag_database_sec(ticker = ticker, year = year,FROM_MARKDOWN = FROM_MARKDOWN)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "a9306dfe-a3b5-48dd-8928-c3f74464ada3",
   "metadata": {},
   "outputs": [],
   "source": [
    "sec_form_system_msg = \"\"\n",
    "#llm_config = {\"model\":\"gpt-4-turbo\"}\n",
    "for sec_form in sec_form_names:\n",
    "    if sec_form == \"10-K\":\n",
    "        sec_form_system_msg+= \"10-K for yearly data, \"\n",
    "    elif \"10-Q\" in sec_form:\n",
    "        quarter = sec_form[-1]\n",
    "        sec_form_system_msg+= f\"{sec_form} for Q{quarter} data, \"\n",
    "sec_form_system_msg = sec_form_system_msg[:-2]\n",
    "\n",
    "earnings_call_system_message = \", \".join(earnings_call_quarter_vals)\n",
    "\n",
    "system_msg = f\"\"\"You are a helpful financial assistant and your task is to select the sec_filings or earnings_call or financial_books to best answer the question.\n",
    "You can use query_database_sec(question,sec_form) by passing question, relevant sec_form names like {sec_form_system_msg}\n",
    "or you can use query_database_earnings_call(question,quarter) by passing question and relevant quarter names with possible values {earnings_call_system_message}\n",
    "or you can use query_database_books(question) to get relevant documents from financial textbooks about valuation and investing philosophies. When you are ready to end the coversation, reply TERMINATE\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "57c76647-d08b-461d-8e63-e9a3f5c9edd3",
   "metadata": {},
   "outputs": [],
   "source": [
    "from autogen import ConversableAgent\n",
    "import os\n",
    "\n",
    "\n",
    "config_list = autogen.config_list_from_json(\n",
    "    \"../OAI_CONFIG_LIST\",\n",
    "    filter_dict={\n",
    "        \"model\": [\"gpt-4-0125-preview\"],\n",
    "    },\n",
    ")\n",
    "llm_config = {\n",
    "    \"config_list\": config_list,\n",
    "    \"timeout\": 120,\n",
    "    # \"temperature\": 0 # for debug convenience\n",
    "    \"temperature\": 0.5,\n",
    "}\n",
    "user_proxy = ConversableAgent(\n",
    "    name = \"Planner Admin\",\n",
    "    system_message=system_msg,\n",
    "    code_execution_config=False,\n",
    "    llm_config=llm_config,\n",
    "    human_input_mode=\"NEVER\",\n",
    "    is_termination_msg=lambda msg: \"TERMINATE\" in msg[\"content\"],\n",
    ")\n",
    "tool_proxy = ConversableAgent(\n",
    "  name=\"Tool Proxy\",\n",
    "  system_message=\"Analyze the response from user proxy and decide whether the suggested database is suitable \"\n",
    "  \". Answer in simple yes or no\",\n",
    "  llm_config=False,\n",
    "  # is_termination_msg=lambda msg: \"exit\" in msg.get(\"content\",\"\"),\n",
    "  default_auto_reply=\"Please select the right database.\",\n",
    "  human_input_mode=\"ALWAYS\",\n",
    "  )\n",
    "\n",
    "tools_dict = {\n",
    "        \"sec\":[query_database_sec,\"Tool to query SEC filings database\"],\n",
    "        \"earnings_call\": [query_database_earnings_call, \"Tool to query earnings call transcripts database\"],\n",
    "    }"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "8e7d6103-02e5-4751-87f1-e4d8b0acf532",
   "metadata": {},
   "outputs": [],
   "source": [
    "from autogen import register_function\n",
    "\n",
    "for tool_name,tool in tools_dict.items():\n",
    "  register_function(\n",
    "      tool[0],\n",
    "      caller=user_proxy,\n",
    "      executor=tool_proxy,\n",
    "      name = tool[0].__name__,\n",
    "      description=tool[1]\n",
    "  )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "82728e4b-6b75-49ee-bced-2440c2848b96",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[33mPlanner Admin\u001b[0m (to Tool Proxy):\n",
      "\n",
      "What is the strategy of Nvidia for artificial intelligence?\n",
      "\n",
      "--------------------------------------------------------------------------------\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "Provide feedback to Planner Admin. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n",
      "\u001b[31m\n",
      ">>>>>>>> USING AUTO REPLY...\u001b[0m\n",
      "\u001b[33mTool Proxy\u001b[0m (to Planner Admin):\n",
      "\n",
      "Please select the right database.\n",
      "\n",
      "--------------------------------------------------------------------------------\n",
      "\u001b[33mPlanner Admin\u001b[0m (to Tool Proxy):\n",
      "\n",
      "\u001b[32m***** Suggested tool call (call_myAznQ11sxs0cW4sde6jiIgG): query_database_earnings_call *****\u001b[0m\n",
      "Arguments: \n",
      "{\"question\":\"What is the strategy of Nvidia for artificial intelligence?\",\"quarter\":\"Q3\"}\n",
      "\u001b[32m*********************************************************************************************\u001b[0m\n",
      "\n",
      "--------------------------------------------------------------------------------\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "Provide feedback to Planner Admin. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n",
      "\u001b[31m\n",
      ">>>>>>>> USING AUTO REPLY...\u001b[0m\n",
      "\u001b[35m\n",
      ">>>>>>>> EXECUTING FUNCTION query_database_earnings_call...\u001b[0m\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "ERROR:autogen.runtime_logging:[runtime logging] log_function_use: autogen logger is None\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[33mTool Proxy\u001b[0m (to Planner Admin):\n",
      "\n",
      "\u001b[33mTool Proxy\u001b[0m (to Planner Admin):\n",
      "\n",
      "\u001b[32m***** Response from calling tool (call_myAznQ11sxs0cW4sde6jiIgG) *****\u001b[0m\n",
      "Jen-Hsun Huang: These computing platforms run NVIDIA AI and NVIDIA Omniverse, software libraries and engines that help the companies build and deploy AI to products and services. we this pioneering work and accelerated computing is more vital than ever. Limited by business, general purpose commuting has slowed to a crawl just as AI demands more computing. Scaling through general purchase computing alone is no longer viable, both from a cost or power standpoint. Accelerated computing is the path forward. We look forward to updating you on our progress next quarter. Thanks, everyone. We are quickly adapting to the macro environment. Correcting inventory levels, offering alternative products to data center customers in China and keeping our opex flat for the next few quarters. Our new platforms are off to a great start and formed the foundation for our resumed growth. MRTX is reinventing 3D graphics with ray tracing and AI. The launch of [Inaudible] is phenomenal. Gamers waited in long lines around the world, 4090 stocks sold out quickly. Hopper, with its revolutionary transformer engine is just in time to meet the surging demand for recommender systems, large language models and generative AI. NVIDIA networking is synonymous with the highest data center throughput and enjoying record results. Oren is the world's first computing platform designed for AI-powered autonomous vehicles and robotics and putting automotive on the road to be our next multibillion-dollar platform. These computing platforms run NVIDIA AI and NVIDIA Omniverse, software libraries and engines that Yes. Thanks, CJ. We're making excellent progress in NVIDIA AI enterprise. In fact, you saw probably that we made several announcements this quarter associated with clouds. You know that NVIDIA has a rich ecosystem. And over the years, our rich ecosystem and our software stack has been integrated into developers and start-ups of all kinds, but more so -- more than ever, we're at the tipping point of clouds, and that's fantastic. Because if we could get NVIDIA's architecture and our full stack into every single cloud, we could reach more customers more quickly. And this quarter, we announced several initiatives, one has several partnerships and collaborations, one that we announced today, which has to do with Microsoft and our partnership there. It has everything to do with scaling up AI because we have so many start-ups clamoring for large installations of our GPU so that they could do large language model training and building their start-ups and scale out of AI to enterprise and all of the world's Internet\n",
      "\n",
      "Colette Kress: 500 system featuring our H-100 GPUs. At GTC, we announced the NVIDIA Omniverse Computing System, or OVS, reference designs featuring the new L4 GPU based on the ADA Lovelace architecture. These systems are designed to build and operate 3D virtual world using NVIDIA Omniverse enterprise. NVIDIA OBX systems will be available from Inspur, Lenovo and Super Micro by early 2023. We Lockheed Martin and Jaguar Land Rover will be among the first customers to receive OVS systems. We are further expanding our AI software and services offerings with NVIDIA and Bio Nemo large language model services, which are both entering early access this month. These enable developers to easily adopt large language models and deploy customized AI applications for content generation, tech summarization, chatbox, co-development, protein structure and biomolecular property predictions. Moving to gaming. Revenue of $1.57 billion was down 23% sequentially and down 51% from a year ago, reflecting lower sell-in to partners to help align momentum. We achieved an important milestone this quarter with VMware. And whose leading server virtualization platform, vSphere, has been rearchitected over the last two years to run on DPUs and now supports our BlueField DPUs. Our joint enterprise AI platform is available first on Dell PowerEdge servers. The BlueField DPU design win pipeline is growing and the number of infrastructure softer partners is expanding, including Arista, Check Point, Juniper, [Inaudible] Networks and Red Hot. The latest top 500 list of supercomputers released this week at Supercomputing '22 and has the highest ever number of NVIDIA-powered systems, including 72% of the total and 90% of new systems on the list. Moreover, NVIDIA powers 23 of the top 30 of the Green 500 list, demonstrating the energy efficiency of accelerated computing. The No. 1 most energy-efficient system is the Flat Iron Institute Henry, which is the first top 500 system featuring our H-100 GPUs. At GTC, we announced the NVIDIA Omniverse Computing System, or\n",
      "\n",
      "\n",
      "\u001b[32m**********************************************************************\u001b[0m\n",
      "\n",
      "--------------------------------------------------------------------------------\n",
      "\u001b[33mPlanner Admin\u001b[0m (to Tool Proxy):\n",
      "\n",
      "Nvidia's strategy for artificial intelligence (AI) is centered on pioneering work in accelerated computing to meet the increasing demands of AI, which requires more computing power than what general-purpose computing can viably provide. The company is adapting to the macro environment by correcting inventory levels, offering alternative products to data center customers in China, and maintaining operational expenditure for the coming quarters. Nvidia is focusing on new platforms that form the foundation for its resumed growth, such as:\n",
      "\n",
      "- **MRTX** for reinventing 3D graphics with ray tracing and AI.\n",
      "- **Hopper**, featuring a revolutionary transformer engine designed to meet the surging demand for recommender systems, large language models, and generative AI.\n",
      "- **NVIDIA Networking** for the highest data center throughput.\n",
      "- **Oren**, the world's first computing platform designed for AI-powered autonomous vehicles and robotics, aiming to become Nvidia's next multibillion-dollar platform.\n",
      "\n",
      "These platforms run NVIDIA AI and NVIDIA Omniverse, software libraries, and engines that help companies build and deploy AI to products and services. Additionally, Nvidia is expanding its AI software and services offerings with NVIDIA and Bio Nemo large language model services, enabling developers to easily adopt large language models and deploy customized AI applications for various purposes.\n",
      "\n",
      "Nvidia's strategy also emphasizes partnerships and collaborations to integrate Nvidia's architecture and full stack into every cloud to reach more customers quickly. This includes significant partnerships like the one with Microsoft to scale up AI, and the integration of Nvidia's architecture into leading server virtualization platforms like VMware's vSphere, which now supports Nvidia's BlueField DPUs.\n",
      "\n",
      "In summary, Nvidia's AI strategy is focused on accelerated computing, innovative platforms for AI and graphics, expanding AI software and services, and strategic partnerships to integrate its technology into broader ecosystems to address the increasing demands of AI applications.\n",
      "\n",
      "--------------------------------------------------------------------------------\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "Provide feedback to Planner Admin. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n",
      "\u001b[31m\n",
      ">>>>>>>> USING AUTO REPLY...\u001b[0m\n",
      "\u001b[33mTool Proxy\u001b[0m (to Planner Admin):\n",
      "\n",
      "Please select the right database.\n",
      "\n",
      "--------------------------------------------------------------------------------\n",
      "\u001b[33mPlanner Admin\u001b[0m (to Tool Proxy):\n",
      "\n",
      "query_database_earnings_call\n",
      "\n",
      "--------------------------------------------------------------------------------\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "Provide feedback to Planner Admin. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n",
      "\u001b[31m\n",
      ">>>>>>>> USING AUTO REPLY...\u001b[0m\n",
      "\u001b[33mTool Proxy\u001b[0m (to Planner Admin):\n",
      "\n",
      "Please select the right database.\n",
      "\n",
      "--------------------------------------------------------------------------------\n",
      "\u001b[33mPlanner Admin\u001b[0m (to Tool Proxy):\n",
      "\n",
      "TERMINATE\n",
      "\n",
      "--------------------------------------------------------------------------------\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "Provide feedback to Planner Admin. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n",
      "\u001b[31m\n",
      ">>>>>>>> USING AUTO REPLY...\u001b[0m\n",
      "\u001b[33mTool Proxy\u001b[0m (to Planner Admin):\n",
      "\n",
      "Please select the right database.\n",
      "\n",
      "--------------------------------------------------------------------------------\n",
      "\u001b[33mPlanner Admin\u001b[0m (to Tool Proxy):\n",
      "\n",
      "TERMINATE\n",
      "\n",
      "--------------------------------------------------------------------------------\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide feedback to Planner Admin. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "input_text = \"What is the strategy of Nvidia for artificial intelligence?\"\n",
    "chat_result = user_proxy.initiate_chat(\n",
    "        recipient=tool_proxy,\n",
    "        message=input_text,\n",
    "        max_turns=10\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "0519715b-4337-4583-95ff-682c5a098874",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[33mPlanner Admin\u001b[0m (to Tool Proxy):\n",
      "\n",
      "What was forward estimates of Nvidia for the year 2023?\n",
      "\n",
      "--------------------------------------------------------------------------------\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "Provide feedback to Planner Admin. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n",
      "\u001b[31m\n",
      ">>>>>>>> USING AUTO REPLY...\u001b[0m\n",
      "\u001b[33mTool Proxy\u001b[0m (to Planner Admin):\n",
      "\n",
      "Please select the right database.\n",
      "\n",
      "--------------------------------------------------------------------------------\n",
      "\u001b[33mPlanner Admin\u001b[0m (to Tool Proxy):\n",
      "\n",
      "\u001b[32m***** Suggested tool call (call_eHeZHC88aTbZpqwDx2vW2lG3): query_database_sec *****\u001b[0m\n",
      "Arguments: \n",
      "{\"question\":\"What was forward estimates of Nvidia for the year 2023?\",\"sec_form_name\":\"10-K\"}\n",
      "\u001b[32m***********************************************************************************\u001b[0m\n",
      "\n",
      "--------------------------------------------------------------------------------\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "Provide feedback to Planner Admin. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n",
      "\u001b[31m\n",
      ">>>>>>>> USING AUTO REPLY...\u001b[0m\n",
      "\u001b[33mTool Proxy\u001b[0m (to Planner Admin):\n",
      "\n",
      "\u001b[33mTool Proxy\u001b[0m (to Planner Admin):\n",
      "\n",
      "\u001b[32m***** Response from calling tool (call_eHeZHC88aTbZpqwDx2vW2lG3) *****\u001b[0m\n",
      "Error: Function query_database_sec not found.\n",
      "\u001b[32m**********************************************************************\u001b[0m\n",
      "\n",
      "--------------------------------------------------------------------------------\n",
      "\u001b[33mPlanner Admin\u001b[0m (to Tool Proxy):\n",
      "\n",
      "\u001b[32m***** Suggested tool call (call_GyHn4bMKS3JxrVOkf4c9N0fD): query_database_unstructured_sec *****\u001b[0m\n",
      "Arguments: \n",
      "{\"question\":\"What was forward estimates of Nvidia for the year 2023?\",\"sec_form_name\":\"10-K\"}\n",
      "\u001b[32m************************************************************************************************\u001b[0m\n",
      "\n",
      "--------------------------------------------------------------------------------\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "Provide feedback to Planner Admin. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n",
      "\u001b[31m\n",
      ">>>>>>>> USING AUTO REPLY...\u001b[0m\n",
      "\u001b[35m\n",
      ">>>>>>>> EXECUTING FUNCTION query_database_unstructured_sec...\u001b[0m\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "ERROR:autogen.runtime_logging:[runtime logging] log_function_use: autogen logger is None\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[33mTool Proxy\u001b[0m (to Planner Admin):\n",
      "\n",
      "\u001b[33mTool Proxy\u001b[0m (to Planner Admin):\n",
      "\n",
      "\u001b[32m***** Response from calling tool (call_GyHn4bMKS3JxrVOkf4c9N0fD) *****\u001b[0m\n",
      "FORM_SUMMARY: to fiscal year 2021 can be found under Item 7 in our Annual Report on Form 10-K for the fiscal year ended January 30, 2022, filed with the SEC on March 18, 2022, which is available free of charge on the SEC’s website at http://www.sec.gov and at our investor relations website, http://investor.nvidia.com. The following table sets forth, for the periods indicated, certain items in our Consolidated Statements of Income expressed as a percentage of revenue. The year-on-year increase was led by growth from hyperscale customers and also reflects purchases made by several CSP partners to support multi-year cloud service agreements for our new NVIDIA AI cloud service offerings and our research and development activities. The increase was also related to the growth in Automotive. CMP contributed an insignificant amount in fiscal year 2023 compared to $550 million in fiscal year 2022. The year-on-year decrease primarily reflects lower sell-in to partners to help reduce channel inventory levels as global macro-economic to fiscal year 2021 can be found under Item 7 in our Annual Report on Form 10-K for the fiscal year ended January 30, 2022, filed with the SEC on March 18, 2022, which is available free of charge on the SEC’s website at http://www.sec.gov and at our investor relations website, http://investor.nvidia.com. The following table sets forth, for the periods indicated, certain items in our Consolidated Statements of Income expressed as a percentage of revenue. The year-on-year increase was led by growth from hyperscale customers and also reflects purchases made by several CSP partners to support multi-year cloud service agreements for our new NVIDIA AI cloud service offerings and our research and development activities. The increase was also related to the growth in Automotive. CMP contributed an insignificant amount in fiscal year 2023 compared to $550 million in fiscal year 2022. The year-on-year decrease primarily reflects lower sell-in to partners to help reduce channel inventory levels as global macro-economic 2012, our shareholders approved the NVIDIA Corporation 2012 Employee Stock Purchase Plan, as most recently amended and restated, or the 2012 Plan. The following is a summary of our equity award transactions under our equity incentive plans: Vested restricted stock Canceled and forfeited Vested and expected to vest after January 29, 2023 As of January 29, 2023 and January 30, 2022, there were 160 million and 131 million shares, respectively, of common stock available for future grants under our equity incentive plans. The total fair value of RSUs and PSUs, as of their respective vesting dates, during the years ended January 29, 2023, January 30, 2022, and January 31, 2021, was $4.27 billion, $5.56 billion, and $2.67 billion, respectively. The following is a reconciliation of the denominator of the basic and diluted net income per share computations for the periods presented: Basic weighted average shares Diluted weighted average shares Equity awards excluded from diluted net income per share because their Consolidated Statements of Income for the years ended January 29, 2023, January 30, 2022, and January 31, 2021 The exhibits listed in the accompanying index to exhibits are filed or incorporated by reference as a part of this Annual Report on Form 10-K. We have audited the accompanying consolidated balance sheets of NVIDIA Corporation and its subsidiaries (the “Company”) as of January 29, 2023 and January 30, 2022, and the related consolidated statements of income, comprehensive income, shareholders' equity and cash flows for each of the three years in the period ended January 29, 2023, including the related notes and financial statement schedule listed in the index appearing under Item 15(a)(2) (collectively referred to as the “consolidated financial statements”). We also have audited the Company's internal control over financial reporting as of January 29, 2023, based on criteria established in k (2013) issued by the Committee of Sponsoring Organizations of the Treadway Commission (COSO). In our opinion, Information regarding ownership of NVIDIA securities required by this item will be contained in our 2023 Proxy Statement under the caption “Security Ownership of Certain Beneficial Owners and Management,” and is hereby incorporated by reference. Information regarding our equity compensation plans required by this item will be contained in our 2023 Proxy Statement under the caption \"Equity Compensation Plan Information,\" and is hereby incorporated by reference.\n",
      "\n",
      "\n",
      "\u001b[32m**********************************************************************\u001b[0m\n",
      "\n",
      "--------------------------------------------------------------------------------\n",
      "\u001b[33mPlanner Admin\u001b[0m (to Tool Proxy):\n",
      "\n",
      "The forward estimates for Nvidia for the year 2023, as detailed in their 10-K filing, highlight several key points:\n",
      "\n",
      "- **Growth from Hyperscale Customers:** Nvidia experienced significant year-on-year increase led by growth from hyperscale customers. This also includes purchases made by several Cloud Service Providers (CSP) partners to support multi-year cloud service agreements for Nvidia's new AI cloud service offerings and research and development activities.\n",
      "- **Automotive Sector Growth:** There was notable growth in the Automotive segment, contributing to Nvidia's overall revenue increase.\n",
      "- **Decrease in CMP Contribution:** The Cryptocurrency Mining Processor (CMP) contributed an insignificant amount in fiscal year 2023 compared to $550 million in fiscal year 2022. This decrease primarily reflects the strategy to lower sell-in to partners to help reduce channel inventory levels amidst global macro-economic conditions.\n",
      "- **Equity Award Transactions:** As of January 29, 2023, there were 160 million shares of common stock available for future grants under Nvidia's equity incentive plans, compared to 131 million shares as of January 30, 2022. The total fair value of vested Restricted Stock Units (RSUs) and Performance Stock Units (PSUs) as of their respective vesting dates during the years ended January 29, 2023, was $4.27 billion.\n",
      "- **Shareholder Equity and Financial Reporting:** The filing includes audited consolidated financial statements for Nvidia Corporation and its subsidiaries as of January 29, 2023, and for the three years in the period ended January 29, 2023. This also encompasses the company's internal control over financial reporting based on criteria established in 2013 by the Committee of Sponsoring Organizations of the Treadway Commission (COSO).\n",
      "\n",
      "These elements provide a comprehensive overview of Nvidia's forward estimates and strategic focus areas for 2023, emphasizing growth in specific sectors such as hyperscale and automotive, adjustments in product contributions, and financial planning regarding equity awards and shareholder equity.\n",
      "\n",
      "--------------------------------------------------------------------------------\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "Provide feedback to Planner Admin. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n",
      "\u001b[31m\n",
      ">>>>>>>> USING AUTO REPLY...\u001b[0m\n",
      "\u001b[33mTool Proxy\u001b[0m (to Planner Admin):\n",
      "\n",
      "Please select the right database.\n",
      "\n",
      "--------------------------------------------------------------------------------\n",
      "\u001b[33mPlanner Admin\u001b[0m (to Tool Proxy):\n",
      "\n",
      "TERMINATE\n",
      "\n",
      "--------------------------------------------------------------------------------\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "Provide feedback to Planner Admin. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide feedback to Planner Admin. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n",
      "\u001b[31m\n",
      ">>>>>>>> USING AUTO REPLY...\u001b[0m\n",
      "\u001b[33mTool Proxy\u001b[0m (to Planner Admin):\n",
      "\n",
      "Please select the right database.\n",
      "\n",
      "--------------------------------------------------------------------------------\n",
      "\u001b[33mPlanner Admin\u001b[0m (to Tool Proxy):\n",
      "\n",
      "The right database to query for forward estimates of Google for the year 2023 would be the SEC filings, specifically the 10-K form, which I have already queried.\n",
      "\n",
      "--------------------------------------------------------------------------------\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide feedback to Planner Admin. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n",
      "\u001b[31m\n",
      ">>>>>>>> USING AUTO REPLY...\u001b[0m\n",
      "\u001b[33mTool Proxy\u001b[0m (to Planner Admin):\n",
      "\n",
      "Please select the right database.\n",
      "\n",
      "--------------------------------------------------------------------------------\n",
      "\u001b[33mPlanner Admin\u001b[0m (to Tool Proxy):\n",
      "\n",
      "TERMINATE\n",
      "\n",
      "--------------------------------------------------------------------------------\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide feedback to Planner Admin. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "input_text = \"What was forward estimates of Nvidia for the year 2023?\"\n",
    "chat_result = user_proxy.initiate_chat(\n",
    "        recipient=tool_proxy,\n",
    "        message=input_text,\n",
    "        max_turns=10\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "ca49d019-6daa-4779-b618-f3ab78bf987d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[33mPlanner Admin\u001b[0m (to Tool Proxy):\n",
      "\n",
      "What are the risk factors that Nvidia faced this year?\n",
      "\n",
      "--------------------------------------------------------------------------------\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "Provide feedback to Planner Admin. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n",
      "\u001b[31m\n",
      ">>>>>>>> USING AUTO REPLY...\u001b[0m\n",
      "\u001b[33mTool Proxy\u001b[0m (to Planner Admin):\n",
      "\n",
      "Please select the right database.\n",
      "\n",
      "--------------------------------------------------------------------------------\n",
      "\u001b[33mPlanner Admin\u001b[0m (to Tool Proxy):\n",
      "\n",
      "\u001b[32m***** Suggested tool call (call_0Ha15DmROFeRgWFOqKKAqAfB): query_database_unstructured_sec *****\u001b[0m\n",
      "Arguments: \n",
      "{\"question\":\"What are the risk factors that Nvidia faced this year?\",\"sec_form_name\":\"10-K\"}\n",
      "\u001b[32m************************************************************************************************\u001b[0m\n",
      "\n",
      "--------------------------------------------------------------------------------\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "Provide feedback to Planner Admin. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n",
      "\u001b[31m\n",
      ">>>>>>>> USING AUTO REPLY...\u001b[0m\n",
      "\u001b[35m\n",
      ">>>>>>>> EXECUTING FUNCTION query_database_unstructured_sec...\u001b[0m\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "ERROR:autogen.runtime_logging:[runtime logging] log_function_use: autogen logger is None\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[33mTool Proxy\u001b[0m (to Planner Admin):\n",
      "\n",
      "\u001b[33mTool Proxy\u001b[0m (to Planner Admin):\n",
      "\n",
      "\u001b[32m***** Response from calling tool (call_0Ha15DmROFeRgWFOqKKAqAfB) *****\u001b[0m\n",
      "FORM_SUMMARY: In evaluating NVIDIA, the following risk factors should be considered in addition to the other information in this Annual Report on Form 10-K. Purchasing or owning NVIDIA common stock involves investment risks including, but not limited to, the risks described below. Any one of the following risks could harm our business, financial condition, results of operations or reputation, which could cause our stock price to decline, and you may lose all or a part of your investment. Additional risks, trends and uncertainties not presently known to us or that we currently believe are immaterial may also harm our business, financial condition, results of operations or reputation. Failure to meet the evolving needs of our industry and markets may adversely impact our financial results. Competition in our current and target markets could cause us to lose market share and revenue. Failure to estimate customer demand properly has led and could lead to mismatches between supply and demand. Dependency on third-party suppliers to fiscal year 2021 can be found under Item 7 in our Annual Report on Form 10-K for the fiscal year ended January 30, 2022, filed with the SEC on March 18, 2022, which is available free of charge on the SEC’s website at http://www.sec.gov and at our investor relations website, http://investor.nvidia.com. The following table sets forth, for the periods indicated, certain items in our Consolidated Statements of Income expressed as a percentage of revenue. The year-on-year increase was led by growth from hyperscale customers and also reflects purchases made by several CSP partners to support multi-year cloud service agreements for our new NVIDIA AI cloud service offerings and our research and development activities. The increase was also related to the growth in Automotive. CMP contributed an insignificant amount in fiscal year 2023 compared to $550 million in fiscal year 2022. The year-on-year decrease primarily reflects lower sell-in to partners to help reduce channel inventory levels as global macro-economic to fiscal year 2021 can be found under Item 7 in our Annual Report on Form 10-K for the fiscal year ended January 30, 2022, filed with the SEC on March 18, 2022, which is available free of charge on the SEC’s website at http://www.sec.gov and at our investor relations website, http://investor.nvidia.com. The following table sets forth, for the periods indicated, certain items in our Consolidated Statements of Income expressed as a percentage of revenue. The year-on-year increase was led by growth from hyperscale customers and also reflects purchases made by several CSP partners to support multi-year cloud service agreements for our new NVIDIA AI cloud service offerings and our research and development activities. The increase was also related to the growth in Automotive. CMP contributed an insignificant amount in fiscal year 2023 compared to $550 million in fiscal year 2022. The year-on-year decrease primarily reflects lower sell-in to partners to help reduce channel inventory levels as global macro-economic may decline. Remediation of any material weakness could require us to incur significant expenses, and if we fail to remediate any material weakness, our financial statements may be inaccurate, we may be required to restate our financial statements, our ability to report our financial results on a timely and accurate basis may be adversely affected, our access to the capital markets may be restricted, our stock price may decline, and we may be subject to sanctions or investigation by regulatory authorities. The COVID-19 pandemic has affected and could continue to have a material adverse impact on our financial condition and results of operations. The COVID-19 pandemic has impacted and may continue to impact our workforce and operations and those of our customers, partners, vendors and suppliers. COVID-19-related disruptions have created and may continue to create supply chain and logistics constraints, and COVID-19 containment around the world has put restrictions on, among other areas, manufacturing actions as required by government regulations or in the best interests of our employees, customers, partners and suppliers. These and other measures have caused and may in the future cause us to incur incremental expenses and costs. The extent of the impact of the COVID-19 pandemic on our operational and financial performance and our ability to timely execute our business strategies may continue to be difficult to measure and predict. The impact of COVID-19 can also exacerbate other risks discussed in these risk factors. Our operating results have in the past fluctuated and may in the future fluctuate, and if our operating results are below the expectations of securities analysts or investors, our stock price could decline. Our operating results have in the past fluctuated and may continue to fluctuate due to numerous factors described in these risk factors. Therefore, investors should not rely on past comparisons of our results of operations as an indication of our future performance. Additional factors\n",
      "\n",
      "\n",
      "\u001b[32m**********************************************************************\u001b[0m\n",
      "\n",
      "--------------------------------------------------------------------------------\n",
      "\u001b[33mPlanner Admin\u001b[0m (to Tool Proxy):\n",
      "\n",
      "NVIDIA faced several risk factors this year, as outlined in their 10-K filing. These include, but are not limited to:\n",
      "\n",
      "1. **Evolving Industry Needs**: Failure to meet the evolving needs of the industry and markets may adversely impact NVIDIA's financial results.\n",
      "\n",
      "2. **Competition**: Competition in NVIDIA's current and target markets could cause the company to lose market share and revenue.\n",
      "\n",
      "3. **Demand Estimation**: Failure to properly estimate customer demand has led and could lead to mismatches between supply and demand.\n",
      "\n",
      "4. **Dependency on Third-Party Suppliers**: NVIDIA's dependency on third-party suppliers could affect its operations.\n",
      "\n",
      "5. **Global Macroeconomic Conditions**: Lower sell-in to partners to help reduce channel inventory levels reflects concerns about global macro-economic conditions.\n",
      "\n",
      "6. **Material Weakness and Financial Reporting**: Remediation of any material weakness could require significant expenses, and failure to remediate any material weakness could lead to inaccurate financial statements, restricted access to capital markets, and potential regulatory sanctions or investigations.\n",
      "\n",
      "7. **COVID-19 Pandemic**: The COVID-19 pandemic has had and could continue to have a material adverse impact on NVIDIA's financial condition and results of operations. It has affected NVIDIA's workforce and operations, as well as those of its customers, partners, vendors, and suppliers, leading to supply chain and logistics constraints.\n",
      "\n",
      "8. **Operational and Financial Performance Fluctuations**: NVIDIA's operating results have fluctuated in the past and may continue to fluctuate, which could lead to a decline in its stock price if results are below the expectations of securities analysts or investors.\n",
      "\n",
      "These risk factors highlight the challenges NVIDIA faces in navigating a rapidly changing industry landscape, managing supply chain and operational risks, and responding to global economic and health crises.\n",
      "\n",
      "--------------------------------------------------------------------------------\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "Provide feedback to Planner Admin. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n",
      "\u001b[31m\n",
      ">>>>>>>> USING AUTO REPLY...\u001b[0m\n",
      "\u001b[33mTool Proxy\u001b[0m (to Planner Admin):\n",
      "\n",
      "Please select the right database.\n",
      "\n",
      "--------------------------------------------------------------------------------\n",
      "\u001b[33mPlanner Admin\u001b[0m (to Tool Proxy):\n",
      "\n",
      "TERMINATE\n",
      "\n",
      "--------------------------------------------------------------------------------\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "Provide feedback to Planner Admin. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide feedback to Planner Admin. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n",
      "\u001b[31m\n",
      ">>>>>>>> USING AUTO REPLY...\u001b[0m\n",
      "\u001b[33mTool Proxy\u001b[0m (to Planner Admin):\n",
      "\n",
      "Please select the right database.\n",
      "\n",
      "--------------------------------------------------------------------------------\n",
      "\u001b[33mPlanner Admin\u001b[0m (to Tool Proxy):\n",
      "\n",
      "TERMINATE\n",
      "\n",
      "--------------------------------------------------------------------------------\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide feedback to Planner Admin. Press enter to skip and use auto-reply, or type 'exit' to end the conversation:  \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[31m\n",
      ">>>>>>>> NO HUMAN INPUT RECEIVED.\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "input_text = \"What are the risk factors that Nvidia faced this year?\"\n",
    "chat_result = user_proxy.initiate_chat(\n",
    "        recipient=tool_proxy,\n",
    "        message=input_text,\n",
    "        max_turns=10\n",
    "    )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "36f5f76a-b14f-4c58-8ab7-4c7d7537b325",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
